using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Text;
using System.Web;
using System.Web.Mail;
using System.Web.Services.Protocols;
using System.Xml;

namespace PlaySpark.Web.WebServices
{
	public class result : SoapHeader
	{
		private bool isActive;

		private int resultCode;
		public int ResultCode { get { return resultCode; } set { resultCode = value; resultMessage = getResultMessage(resultCode); } }

		private string resultMessage;
		public string ResultMessage { get { return resultMessage; } set { resultMessage = value; } }

		private string getResultMessage(int resultCode)
		{
			string returnValue = "";

			if (isActive)
			{
				DAL.InterfaceResult daoInterfaceResult = new DAL.InterfaceResult();
				daoInterfaceResult.LoadAndCloseReader(DAL.InterfaceResult.FetchByParameter(DAL.InterfaceResult.Columns.ResultCode, resultCode));

				if (daoInterfaceResult.Id > 0)
				{
					returnValue = daoInterfaceResult.ResultMessage;
				}
				else
				{
					returnValue = "Unknown error";
				}
			}

			return returnValue;
		}

		public void Activate()
		{
			ResultCode = 0;
			isActive = true;
		}

		public result()
		{
			isActive = false;
		}
	}
}
